package com.mmg.spzx.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mmg.spzx.manager.mapper.UserInfoMapper;
import com.mmg.spzx.manager.service.UserInfoService;
import com.mmg.spzx.model.dto.user.UserInfoDto;
import com.mmg.spzx.model.entity.user.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public PageInfo<UserInfo> findByPage(Integer pageNum, Integer pageSize, UserInfoDto userInfoDto) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(userInfoMapper.findByPage(userInfoDto));
    }

    @Override
    public void updateStatus(Integer id, Integer status) {
        //让status取反不是1就是0
        status = status == 1 ? 0 : 1;
        userInfoMapper.updateStatus(id, status);
    }
}
